/*
 * Created on Feb 27, 2005
 */
import java.awt.*;
import java.awt.event.*;
/**
 * @author Jesse Phillips
 */
public class MenuSystem implements ActionListener, ItemListener {
	private MenuBar menuBar;
	private Menu menu;
	private MenuItem menuItem;
	private Frame myFrame;
	private Mousing myMouse;
	
	public MenuSystem(Frame f, Mousing m) {
		myFrame = f;
		myMouse = m;
	}
	
	public MenuBar creatMenuBar() {
		//Menu bar
		menuBar = new MenuBar();
		
		//The menu
		menu = new Menu("Drawing Style");
		menu.getAccessibleContext().setAccessibleDescription(
        	"Different methods of Drawing");
		menuBar.add(menu);
		
		//Menu Items
		menuItem = new MenuItem("Draw line");
		menuItem.getAccessibleContext().setAccessibleDescription(
        	"Draw a line");
		menuItem.addActionListener(this);
		menu.add(menuItem);
		
		menuItem = new MenuItem("Normal Drawing");
		menuItem.getAccessibleContext().setAccessibleDescription(
    		"Follow the cursor drawing");
		menuItem.addActionListener(this);
		menu.add(menuItem);
		
		menuItem = new MenuItem("Dot drawing");
		menuItem.getAccessibleContext().setAccessibleDescription(
    		"Draw dots on the screet");
		menuItem.addActionListener(this);
		menu.add(menuItem);
		
		menuItem = new MenuItem("Oval");
		menuItem.getAccessibleContext().setAccessibleDescription(
    		"Draw ovals on the screet");
		menuItem.addActionListener(this);
		menu.add(menuItem);
		
		//Fill choice
		menu.addSeparator();
		menuItem = new MenuItem("Fill");
        menuItem.addActionListener(this);
        menu.add(menuItem);
        
        //pen size
        menu = new Menu("Pen Size");
        menu.getAccessibleContext().setAccessibleDescription(
    	"Size of the drawing pen");
        menuBar.add(menu);
        
    	menuItem = new MenuItem("1");
    	menuItem.addActionListener(this);
    	menu.add(menuItem);
    	
    	menuItem = new MenuItem("3");
    	menuItem.addActionListener(this);
    	menu.add(menuItem);
    	
    	menuItem = new MenuItem("5");
    	menuItem.addActionListener(this);
    	menu.add(menuItem);
    	
    	menuItem = new MenuItem("10");
    	menuItem.addActionListener(this);
    	menu.add(menuItem);
		
    	//Background
    	menu = new Menu("BackGround");
        menu.getAccessibleContext().setAccessibleDescription(
     		"Change background color");
        menuBar.add(menu);
         
     	menuItem = new MenuItem("White");
     	menuItem.addActionListener(this);
     	menu.add(menuItem);
     	
     	menuItem = new MenuItem("Gray");
     	menuItem.addActionListener(this);
     	menu.add(menuItem);
     	
     	menuItem = new MenuItem("Blue");
     	menuItem.addActionListener(this);
     	menu.add(menuItem);
     	
     	menuItem = new MenuItem("Green");
     	menuItem.addActionListener(this);
     	menu.add(menuItem);
     	
     	menuItem = new MenuItem("Pink");
     	menuItem.addActionListener(this);
     	menu.add(menuItem);
     	
     	menuItem = new MenuItem("Yellow");
     	menuItem.addActionListener(this);
     	menu.add(menuItem);
     	
     	menuItem = new MenuItem("Red");
     	menuItem.addActionListener(this);
     	menu.add(menuItem);
     	
     	menuItem = new MenuItem("Black");
     	menuItem.addActionListener(this);
     	menu.add(menuItem);
    	
    	return menuBar;
	}

	/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	public void actionPerformed(ActionEvent e) {
		//Checking drawing style
		if (e.getActionCommand() == "Normal Drawing"){
			myMouse.setStyle(0);
		}else if(e.getActionCommand() == "Dot drawing") {
			myMouse.setStyle(1);
		}else if(e.getActionCommand() == "Draw line") {
			myMouse.setStyle(2);
		}else if(e.getActionCommand() == "Oval") {
			myMouse.setStyle(3);
		}else if(e.getActionCommand() == "Fill") {
			myMouse.setFill();
		//Checking thickness
		}else if (e.getActionCommand() == "1") {
			myMouse.setThick(1);
		}else if(e.getActionCommand() == "3") { 
			myMouse.setThick(3);
		}else if(e.getActionCommand() == "5") {
			myMouse.setThick(5);
		}else if(e.getActionCommand() == "10") {
			myMouse.setThick(10);
		//check background color
		}else if(e.getActionCommand() == "White") {
			myMouse.setBGColor(Color.white);
		}else if(e.getActionCommand() == "Gray") {
			myMouse.setBGColor(Color.gray);
		}else if(e.getActionCommand() == "Blue") {
			myMouse.setBGColor(Color.blue);
		}else if(e.getActionCommand() == "Green") {
			myMouse.setBGColor(Color.green);
		}else if(e.getActionCommand() == "Pink") {
			myMouse.setBGColor(Color.pink);
		}else if(e.getActionCommand() == "Yellow") {
			myMouse.setBGColor(Color.yellow);
		}else if(e.getActionCommand() == "Red") {
			myMouse.setBGColor(Color.red);
		}else if(e.getActionCommand() == "Black") {
			myMouse.setBGColor(Color.black);
		}
		else {
			System.out.println("Error: could not match menu command.");
		}
	}

	/* (non-Javadoc)
	 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
	 */
	public void itemStateChanged(ItemEvent e) {
		
	}
}
